
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <fcntl.h>
#include <io.h>

#include "pio.h"
#include "prottype.h"

void cdump(int fh,long adr,long len)
{
    size_t l;
    
    setdump(adr,2);
    while(len) {
	l = (len>(TMPSIZE/2))? (TMPSIZE/2):len;
	pio_cpeek(fh,adr,(long)l,buf.s);
	dumps(buf.s,l);
	len -= l;
	adr += l;
    }
}

#ifdef TEST
void main(int ac,char *av[])
{
    int fh;
    long addr,len;
   
    if((fh = open("PCFXPIO$",O_RDWR|O_BINARY))<0) {
	printf("cant open \'pcfxpio.sys\'\n");
	return;
    }

    buf.c = malloc(TMPSIZE);
    if( buf.c == NULL ) {
	printf("malloc error\n");
	close(fh);
	return ;
    }

    addr = 0x0000L; len = 0x80L;
    if(ac>1) sscanf(av[1],"%lx",&addr);
    if(ac>2) sscanf(av[2],"%lx",&len);

    cdump(fh,addr,len);

    close(fh);
    return ;
}
#endif
/* EOF */

